package com.schoolhelper.model;

import com.schoolhelper.utils.MyRedis;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class MyToken {

    private MyRedis myRedis = new MyRedis();

    public static String generateToken(String key, EncryptionI encryptionI) {
        return encryptionI.encrypt(key);
    }

    public boolean check(String key) {
        if (key  == null){
            System.out.println("Check function's parma key couldn't be null!");
            return false;
        }
        String s = myRedis.get(key);
        return s != null;
    }


}
